package com.ytsky.hctechnologysys.config;

import com.ytsky.hctechnologysys.interceptor.LoginInerceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Dell
 */
@Configuration
public class AppConfig implements WebMvcConfigurer {

    //在web环境中加入些拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        //将已定义好的登录拦截器注册到系统中 并返回一个InterceptroRegistration
       final  InterceptorRegistration registration = registry.addInterceptor(new LoginInerceptor());


       registration.addPathPatterns("/**");

       // 注册需要排除拦截的URL模式：1.登录请求不能拦截，否则死循环 2.静态资源不能拦截
        registration.excludePathPatterns("/login","/common/**","/ajax/**","/css/**","/fonts/**","/images/**","/js/**");
    }
}
